home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / FileCbx.tcl.z / FileCbx.tcl
Encoding:
Text File  |  1999-01-26  |  2.1 KB  |  101 lines

  1. # tixFileCombobox --
  2. #
  3. #    A combobox widget for entering file names, directory names, file
  4. #    patterns, etc.
  5. #
  6. #
  7. # Copyright (c) 1996, Expert Interface Technologies
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  
  12. # tixFileComboBox displays and accepts the DOS pathnames only. It doesn't
  13. # recognize UNC file names or Tix VPATHS.
  14. #
  15. tixWidgetClass tixFileComboBox {
  16.     -classname TixFileComboBox
  17.     -superclass tixPrimitive
  18.     -method {
  19.     invoke
  20.     }
  21.     -flag {
  22.     -command -defaultfile -directory -text
  23.     }
  24.     -forcecall {
  25.     -directory
  26.     }
  27.     -configspec {
  28.     {-defaultfile defaultFile DefaultFile ""}
  29.     {-directory directory Directory ""}
  30.     {-command command Command ""}
  31.     {-text text Text ""}
  32.     }
  33.     -default {
  34.     }
  35. }
  36.  
  37. proc tixFileComboBox:InitWidgetRec {w} {
  38.     upvar #0 $w data
  39.  
  40.     tixChainMethod $w InitWidgetRec
  41.  
  42.     if ![string comp $data(-directory) ""] {
  43.     set data(-directory) [tixFSPWD]
  44.     }
  45. }
  46.  
  47. proc tixFileComboBox:ConstructWidget {w} {
  48.     upvar #0 $w data
  49.  
  50.     tixChainMethod $w ConstructWidget
  51.     set data(w:combo) [tixComboBox $w.combo -editable true -dropdown true]
  52.     pack $data(w:combo) -expand yes -fill both
  53. }
  54.  
  55. proc tixFileComboBox:SetBindings {w} {
  56.     upvar #0 $w data
  57.  
  58.     tixChainMethod $w SetBindings
  59.     $data(w:combo) config -command "tixFileComboBox:OnComboCmd $w"
  60. }
  61.  
  62. proc tixFileComboBox:OnComboCmd {w args} {
  63.     upvar #0 $w data
  64.  
  65.     set text [string trim [tixEvent value]]
  66.  
  67.     set fInfo [tixFSNorm [tixFSVPath $data(-directory)] \
  68.     $text $data(-defaultfile) "" errorMsg]
  69.     if [info exists errorMsg] {
  70.  
  71.     } else {
  72.     tixSetSilent $data(w:combo) [lindex $fInfo 0]
  73.     if [string compare $data(-command) ""] {
  74.         set bind(specs) {%V}
  75.         set bind(%V)    $fInfo
  76.         tixEvalCmdBinding $w $data(-command) bind $fInfo
  77.     }
  78.     }
  79. }
  80.  
  81. proc tixFileComboBox:config-text {w val} {
  82.     upvar #0 $w data
  83.  
  84.     tixSetSilent $data(w:combo) $val
  85. }
  86.  
  87. proc tixFileComboBox:config-directory {w val} {
  88.     upvar #0 $w data
  89.  
  90.     set data(-directory) [tixFSNormDir $val]
  91.     return $data(-directory)
  92. }
  93.  
  94. proc tixFileComboBox:invoke {w} {
  95.     upvar #0 $w data
  96.  
  97.     $data(w:combo) invoke
  98. }
  99.  
  100.  
  101.